package emby.stmt;

import emby.EmbyRuntime;
import emby.expr.Expression;
import emby.lang.Scope;
import emby.lang.ThrownObject;
import emby.writer.IEmbyCodifier;

public class Throw extends Statement{

	private static final long serialVersionUID = -3299481229100414946L;
	Expression e;
	public Throw(Expression e){
		this.e=e;
	}

	@Override
	public Object eval(Scope s) {
		Object thrown = e.eval(s);
		if(EmbyRuntime.echo){
			emby.util.Print.println("Attempting to throw "+thrown);
		}
		throw new ThrownObject(thrown);
	}

	public void codify(IEmbyCodifier ec){
		ec.throw_(e);
	}
}
